/**
 * 2019年2月19日上午6:33:24
 * @author 谢进财
 */
package com.baihang.project.ds.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baihang.framework.kit.ShiroKit;
import com.baihang.framework.kit.database.RedisKit;
import com.baihang.framework.service.BaseService;
import com.baihang.project.ds.model.FangYuanModel;

import redis.clients.jedis.Jedis;

/**
 * @author whati
 *
 */
@Service
public class DingDanRedisService extends BaseService {
	private static Logger logger = LoggerFactory.getLogger(DingDanRedisService.class);
	private Jedis jedis = RedisKit.getJedis();
	
	public FangYuanModel getDingDan() {
		logger.info("获取redis订单");
		FangYuanModel  model=null;
		if(jedis.hexists("rengou", ShiroKit.getCurrentUser().getUserName())) {//如果已购房源包含此用户
			String id =  jedis.hmget("rengou", ShiroKit.getCurrentUser().getUserName()).get(0);
			String modelJson = jedis.hmget("rooms", id).get(0);
			model = JSON.parseObject(modelJson, new TypeReference<FangYuanModel>() {});
		}
		return model;
	}
}
